package com.young.ysepay.service.impl;

import com.young.ysepay.service.YsNotifyRegistryService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: WANGNING
 * @Email wyn20140226@aliyun.com
 * @Date: 2019/6/10 17:29
 * @Des 银盛异步回执参数校验
 */
@Service
public class YsNotifyRegistryServiceImpl implements YsNotifyRegistryService {

    @Override
    public Map notifyRegistry(Map<String, String[]> requestParams) {
        StringBuilder sb = new StringBuilder();
        Map<String, Object> params = new HashMap<>();
        sb.append("\r\n 银盛异步回调开始 ");
        for (Map.Entry<String, String[]> entry : requestParams.entrySet()) {
            String name = entry.getKey();
            String[] values = entry.getValue();
            StringBuffer valueStr = null;

            if (values != null) {
                valueStr = new StringBuffer();
                for (int i = 0; i < values.length; i++) {
                    valueStr = (i == values.length - 1) ? valueStr.append(values[i]) : valueStr.append(values[i]).append(",");
                }
                params.put(name, valueStr.toString());
            }

        }
        sb.append("==========YsNotifyRegistryService=============" + params.toString());
        return  params;
    }
}
